package com.zzyl.controller;

import cn.hutool.core.bean.BeanUtil;
import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.ApplicationsDto;
import com.zzyl.dto.PendingTasksDto;
import com.zzyl.entity.PendingTasks;
import com.zzyl.service.ActFlowCommService;
import com.zzyl.utils.UserThreadLocal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/applications")
public class ApplicationsController {

    @Autowired
    private ActFlowCommService actFlowCommService;

    /**
     * 查询我的申请
     * @param dto
     * @return
     */
    @PostMapping("/selectByPage")
    public ResponseResult<PageResponse<PendingTasks>> selectByPage(@RequestBody ApplicationsDto dto){
        PendingTasksDto pendingTasksDto = BeanUtil.toBean(dto, PendingTasksDto.class);
        pendingTasksDto.setApplicatId(UserThreadLocal.getMgtUserId());//设置申请人id
        PageResponse<PendingTasks> pageResponse = actFlowCommService.myTaskList(pendingTasksDto);
        return ResponseResult.success(pageResponse);

    }
}
